#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <climits>
#define int long long 
#define x first 
#define y second 
using namespace std ;
typedef pair<int,int> PII;
const int N = 1e5 + 10;
int a[N];
PII p[N];

void solve()
{
    int cnt = 0;
    int a,b,c;
    cin >> a >> b >> c;
    for(int i = a; i < b; )
    {
        i = i + 2; 
        if(i % c != 0) cnt ++;
        else 
        {
          i = i - 1; 
          cnt ++;
        }
    }
    cout << cnt << endl;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    int t ;
    cin >> t;
    while(t -- ) solve();
    return 0;
}